﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XYW;

namespace xyw.admincp
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.username.Text == "" || this.password.Text == "")
                return;
            XYW.BLL.Users bllUser = new XYW.BLL.Users();
            XYW.Model.Users modelUser = bllUser.GetModel(this.username.Text.Trim());
            if (modelUser != null && modelUser.isSuper.Value == 1)
            {
                if (modelUser.passWord == XYW.Common.DEncrypt.DESEncrypt.Encrypt(this.password.Text))
                {
                    XYW.WebSite.CurUser.IsSuper = true;
                    XYW.WebSite.CurUser.Name = this.username.Text.Trim();
                    XYW.WebSite.CurUser.Id = modelUser.id;
                    XYW.WebSite.CurUser.Role = "admin";

                    Response.Redirect("./Default.aspx");
                }
            }
        }
    }
}